/**
 * H5跨域问题解决方案：https://ask.dcloud.net.cn/article/35267
 * 获取服务器API接口数据
 * 异议联系作者: 国印股份【君莫笑】email: 289803508@qq.com
 * @description url 必填项 ，{ header , data, method } 可入空值则默认GET请求，异常信息在业务页面捕获
 */
function getJSON(url, { header = {}, data = {}, method = 'POST' } = {}) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url:  url,
			header: header,
			data: data,
			method: method,
			success: (result) => {
				const { statusCode, data } = result
				console.warn('request',statusCode,data)
				if(statusCode === 200){
					resolve(data)
				}else{
					reject(result)
				}
			},
			fail: (error) => {
				reject(error)
			}
		})
	})
}


module.exports = {
	getJSON
}
